import { Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import { PostsEntity } from "src/posts/entities/posts.entity";

@Entity('category')
export class CategoryEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({length: 50})
  name: string;

  @OneToMany(() => PostsEntity, post => post.category)
  posts: Array<PostsEntity>

  @CreateDateColumn({
    type: 'timestamp',
    comment: '创建时间',
    name: 'create_time'
  })
  createTime: Date;

  @UpdateDateColumn({
    type: 'timestamp',
    comment: '更新时间',
    name: 'update_time'
  })
  updateTime: Date;
}
